package org.example.springboot.controller;

import org.example.springboot.model.Customers;
import org.example.springboot.model.Items;
import org.example.springboot.service.CustomersService;
import org.example.springboot.service.ItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
public class CustomerController {

    @Autowired
    private CustomersService customersService;

    @PostMapping("/insertCustomer")
    public String insertCustomer(@RequestBody Customers customers){
        return customersService.insertCustomer(customers.getEnterpriseCode(),customers.getCustomerName(),customers.getBankName(),customers.getBankAccount(),customers.getInvoiceNumber(),customers.getCompanyPhone(),customers.getCustomerType(),customers.getCustomerName(),customers.getContactPerson(),customers.getContactPhone(),customers.getCustomerType());
    }

    @GetMapping("/getAllCustomer")
    public List<Customers> getAllCustomer(){
        return customersService.getAllCustomer();
    }

    @GetMapping("/findCustomerByKeyword/{keyword}")
    public List<Customers> findCustomerByKeyword(@PathVariable String keyword){
        return customersService.findCustomerByKeyword(keyword);
    }

    @GetMapping("/findCustomerByCode/{enterpriseCode}")
    public Customers findCustomerByCode(@PathVariable String enterpriseCode){
        return customersService.findCustomerByCode(enterpriseCode);
    }

    @DeleteMapping("/deleteCustomerByCode/{enterpriseCode}")
    public void deleteCustomerByCode(@PathVariable String enterpriseCode){
        customersService.deleteCustomerByCode(enterpriseCode);
    }
}
